package com.lgl.maker.meta;


import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.json.JSONUtil;

/**
 * @author 良哥
 * @verison FileGenerator.java.ftl.0
 */
public class MetaManager {
    private static volatile Meta meta;

    // 构造函数私有化
    private MetaManager() {
    }

    public static Meta getMetaManager() {
        // metaManager不为null,则直接返回
        if (meta == null) {
            synchronized (MetaManager.class) {
                if (meta == null) {
                    meta = initMeta();
                }
            }
        }
        return meta;
    }

    private static Meta initMeta() {
        String JsonStr = ResourceUtil.readUtf8Str("meta.json");
        Meta meta = JSONUtil.toBean(JsonStr, Meta.class);
        return meta;
    }

    public static void main(String[] args) {
        MetaManager.getMetaManager();
        System.out.println(meta.getBasePackage());
    }
}
